﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using SlimDX;
using SlimDX.Direct3D9;

using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace Splino.D3D
{
    /// <summary>
    /// A spline object composed of straight line segments
    /// </summary>
    [Serializable()]
    public class LinearSplineObject : SplineObject
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public LinearSplineObject()
            : base()
        {
            _treeNodeImageKey = "linearSpline";
        }

        /// <summary>
        /// Protected constructor used for creating Point Objects from
        /// clipboard data objects.
        /// </summary>
        /// <param name="info">Clipboard Serialization Info</param>
        /// <param name="context">Clipboard Streaming Context</param>
        protected LinearSplineObject(SerializationInfo info, StreamingContext context)
            : base(info, context) { }

        /// <summary>
        /// Draws the spline object on the screen.
        /// </summary>
        public override void Draw(DrawLayer drawLayer, SplinoViewport splinoViewport)
        {
            base.Draw(drawLayer, splinoViewport);
            if (_drawLayer == drawLayer)
            {
                DeviceManager.Instance.Device.SetStreamSource(
                    0, _vertexBuffer, 0, CustomVertex.PositionColored.SizeInBytes);
                DeviceManager.Instance.Device.DrawPrimitives(
                    PrimitiveType.LineStrip,
                    0,
                    _sceneChildren.Count - 1);
            }
        }

    }
}
